﻿using System.Security.Cryptography;
using System.Text;

namespace FrameWork
{
    partial class AESHelper
    {
        public static byte[] AesDecrypt(byte[] encryptedBytes, string key)
        {
            var keyArray = Encoding.UTF8.GetBytes(key);


            var toEncryptArray = encryptedBytes;

            var rDel = new RijndaelManaged
            {
                Key = keyArray,
                Mode = CipherMode.ECB,
                Padding = PaddingMode.PKCS7
            };

            var cTransform = rDel.CreateDecryptor();
            return cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
        }
    }
}
